//
//  ViewController.m
//  iphone-client
//
//  Created by Sebastian Borggrewe on 14/12/2011.
//  Copyright (c) 2011 Robolo. All rights reserved.
//

#import "ViewController.h"
#import "HunterController.h"
#import "RunnerController.h"
#import "NetworkingCenter.h"

@implementation ViewController
@synthesize chosenTeam = _chosenTeam;

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Release any cached data, images, etc that aren't in use.
}

- (IBAction)playAs:(id)sender {
    if (((UIButton *)sender).tag == HUNTER) {
        HunterController *hunterController = [[HunterController alloc] initWithNibName:@"HunterView" bundle:nil];
        hunterController.currentTeam = self.chosenTeam.selectedSegmentIndex;
        [self presentModalViewController:hunterController animated:YES];
        
        [hunterController release]; hunterController = nil;
        
        
    } else if (((UIButton *)sender).tag == RUNNER) {
        // Runner
        RunnerController *runnerController = [[RunnerController alloc] initWithNibName:@"RunnerView" bundle:nil];
        runnerController.currentTeam = self.chosenTeam.selectedSegmentIndex;
        [self presentModalViewController:runnerController animated:YES];
        
        [runnerController release]; runnerController = nil;
    }
}

- (IBAction)openServerConnection:(id)sender {
    
    
    
    /*UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Connection opening..." message:@"Connection is being established" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
    
    [alertView show];
    [alertView release];*/
    
}

- (void)dealloc {
    [_chosenTeam release];
    [super dealloc];
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    
    //load the background from the image depending on the resolution
    self.view.backgroundColor = [[[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"rolebg.png"]]autorelease];
    self.view.alpha = 0.7;
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated
{
	[super viewWillDisappear:animated];
}

- (void)viewDidDisappear:(BOOL)animated
{
	[super viewDidDisappear:animated];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}

@end
